<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
<?php
include('../../inc/global.inc');
include("../islogin.php");
if($_GET['del_act']){
mysql_query("delete from catalog where id='".$_GET['del_id']."'");
echo "<script>location='catalog.php';</script>";
}

if($_GET['action']=='cache'){
$rs=mysql_query("select id,cat_name,cat_id from catalog order by id asc");
$str = '// JavaScript Document
var onecount;
onecount=0;
subcat=new Array();
';
$i=0;
while($row=mysql_fetch_array($rs))
{
	$row['cat_name']=iconv('UTF-8', 'GB2312', $row['cat_name']);
	$str .=  "subcat[$i]=new Array('".$row['cat_name']."','".$row['cat_id']."','".$row['id']."');\n";
	$i++;
}
$onecount = mysql_num_rows($rs)+0;
$t2=iconv('UTF-8', 'GB2312', '二级分类');
$t3=iconv('UTF-8', 'GB2312', '三级分类');

$str .='
onecount='.$onecount.';

function changelocation(locationid){   
   document.form1.catalog_2.length=0;     
   var locationid=locationid;   
   var i;   
   for(i=0;i<onecount;i++){   
       if(i==0){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option("--'.$t2.'--","");
		  }   
       if(subcat[i][1]==locationid){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option(subcat[i][0],subcat[i][2]);   
          }                   
    }   
}

function changelocation2(locationid2)   
{   
document.form1.catalog_3.length=0;     
var locationid2=locationid2;   
var i2;   
for (i2=0;i2<onecount;i2++){   
     if(i2==0){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option("--'.$t3.'--","");     
         }   
     if(subcat[i2][1]==locationid2){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option(subcat[i2][0],   subcat[i2][2]);   
         }                   
     }   
}';

@file_put_contents(PHPCMS_ROOT."member/js/catalog.js",$str);
echo "<script>alert('更新成功');location='catalog.php';</script>";
}
?>
</HEAD>
<BODY>
<center>
  <table width="70%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">产品目录 &nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
      <td bgcolor="#EEEEF9" style="padding-left:5px;"><a href="?action=cache">更新缓存</a></td>
    </tr>
  </table>
  <table width="70%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="9%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="30%" align="center" bgcolor="#8DA8CF">产品目录名</td>
      <td width="17%" align="center" bgcolor="#8DA8CF">大类名称-编号</td>
      <td width="9%" align="center" bgcolor="#8DA8CF">首页</td>
      <td width="9%" align="center" bgcolor="#8DA8CF">产品</td>
      <td width="9%" align="center" bgcolor="#8DA8CF">图片</td>
      <td width="17%" align="center" bgcolor="#8DA8CF"><a href="catalog_modify.php?tj=ok&id=<?=$_GET[id]?>">添加产品目录</span></a></td>
    </tr>
<?php
if($_GET[id]){
$sql="select * from catalog where cat_id='".$_GET['id']."' order by id asc";
}else{
$sql="select * from catalog where cat_id=0 order by id asc";}
$rs=mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
$rs2=mysql_query("select * from catalog where cat_id='".$row['id']."'");
$row2=mysql_fetch_array($rs2);
$num=mysql_num_rows($rs2);
mysql_free_result($rs2);
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="left" style="padding-left:10px;"><?php if($row[c_ping]){echo "<font color='blue'>$row[c_ping]</font>-";}?><?=$row[cat_name]?>(<a href='catalog.php?id=<?=$row['id']?>'><font color='red'><?=$num?></font></a>)</td>
      <td align="center" style="padding-left:10px;"><?=$row[big_name]?>-<?=$row[big_name_id]?></td>
      <td align="center" style="padding-left:10px;"><?php if($row[c_top_tj]==1){echo "<font color='red'>是</font>";}else{echo "否";}?></td>
      <td align="center" style="padding-left:10px;"><?php if($row[c_tj]==1){echo "<font color='red'>是</font>";}else{echo "否";}?></td>
      <td align="center" style="padding-left:10px;"><?php if($row[c_photo]){echo "<font color='red'>是</font>";}else{echo "否";}?></td>
      <td align="center"><a href="catalog_modify.php?xg=ok&xg_id=<?=$row['id']?>">编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="catalog.php?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;}
?>
  </table>
</center>
</BODY>
</HTML>
